:root {
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --page-bg:#FFFFFF;
    --sidebar-bg: #DFF1FE;
    --primary-text-color: #333333;
    --secondary-text-color: #100f0f;
    --border-color: #DFF1FE;
    --user-message-bg: #E8F5E9;
    --ai-message-bg:  #FDF5E6;
    --sidebar-hover-bg: #f0f2f4;
    --primary-accent: #2e713b;
    --highlight-bg: #fff2a8;
}
/* CSS部分需添加：*/
.hidden {
    display: none !important;
}


/* 音频预览样式 */
.audio-preview-wrapper {
    position: relative;
    margin: 10px 0;
    padding: 10px;
    background: #f5f5f5;
    border-radius: 8px;
}
/* 消息气泡调整 */
.message {
    max-width: 90%;
    min-width: 200px;
}

/* 音频消息容器 */
.audio-message-container {
    width: 100%;
    max-width: 300px;
}

/* 音频控制条 */
audio {
    width: 100% !important;
    min-width: 250px;
}
.audio-preview-wrapper audio {
    width: 100%;
    height: 40px;
}

.audio-preview-remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
}
/*用户管理*/
/* 修改用户管理区域样式 */

#user-management-button {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 6px 8px; /* 减小按钮内边距 */
  background: #cfdfec;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 0.9em; /* 减小字体大小 */
  border-radius: 8px;
}

.user-avatar {
  width: 28px; /* 减小头像尺寸 */
  height: 28px;
  margin-right: 8px; /* 减小右边距 */
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-right: 10px;
}

.user-avatar-large {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin-bottom: 10px;
}

#user-panel {
  position: fixed;
  bottom: -300px;
  left: 0;
  width: 15%;
  height: 250px;
  background: white;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  transition: transform 0.3s ease-in-out;
  padding: 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-radius: 10px;
}

#user-panel.show {
  transform: translateY(-300px);
}

.user-info {
  text-align: center;
}

#logout-button {
  padding: 10px;
  background: #ff4d4d;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#logout-button:hover {
  background: #ff3333;
}

html, body {
    height: 100vh; width: 100vw; margin: 0; overflow: hidden;
    font-family: var(--font-family); background-color: var(--page-bg); color: var(--primary-text-color);
}

#app-container { display: flex; height: 100%; width: 100%; }
#sidebar {
    display: flex; flex-direction: column; width: 280px; background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color); padding: 10px; flex-shrink: 0; height: 100%;
    box-sizing: border-box; transition: margin-left 0.3s ease-in-out;
}
#app-container.sidebar-collapsed #sidebar { margin-left: -280px; }
#sidebar-header { display: flex; align-items: center; padding-bottom: 10px; }
#new-chat-button {
    width: 100%; background-color: transparent; border: 1px solid var(--secondary-text-color);
    color: var(--primary-text-color); padding: 8px 12px; border-radius: 8px; text-align: center; cursor: pointer;
    font-size: 0.9em; transition: all 0.2s;
}
#new-chat-button:hover { background-color: var(--sidebar-hover-bg); border-color: var(--primary-accent); }
#conversation-list {
    list-style: none; padding: 0; margin: 0; overflow-y: auto; flex-grow: 1;
}
#conversation-list li {
    padding: 12px 15px; border-radius: 6px; cursor: pointer; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; font-size: 0.9em; transition: background-color 0.2s;
    color: var(--secondary-text-color);
}
#conversation-list li:hover { background-color: var(--sidebar-hover-bg); }
#conversation-list li.active { background-color: #e0f0e0; color: var(--primary-accent); font-weight: 500; }

#chat-container { flex-grow: 1; display: flex; flex-direction: column; height: 100vh; }
#chat-toolbar {
    display: flex; align-items: center; padding: 8px 20px; border-bottom: 1px solid var(--border-color);
    background-color: #DFF1FE; gap: 16px; flex-shrink: 0;
}
#sidebar-toggle { background: none; border: none; cursor: pointer; padding: 5px; margin-right: 8px; }
#sidebar-toggle svg { width: 24px; height: 24px; fill: var(--secondary-text-color); }
.toolbar-group { display: flex; align-items: center; gap: 8px; position: relative; color: #01080b
}
.toolbar-group label { font-size: 0.85em; color: var(--secondary-text-color); }
#search-input, #model-selector {
    border: 1px solid var(--border-color); border-radius: 6px; padding: 6px 10px; font-size: 0.9em;
    background-color: #fff; color: var(--primary-text-color);
}
#search-input, #mode-selector {
    border: 1px solid var(--border-color); border-radius: 6px; padding: 6px 10px; font-size: 0.9em;
    background-color: #fff; color: var(--primary-text-color);
}
#search-input { min-width: 250px; }
#clear-search-btn { font-size: 1.2em; cursor: pointer; color: var(--secondary-text-color); display: none; }
#search-results-overlay {
    display: none; position: absolute; top: 110%; left: 0;
    width: 450px; max-height: 50vh; overflow-y: auto; background-color: #fff;
    border: 1px solid var(--border-color); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 100;
}
.search-result-item { padding: 10px 15px; border-bottom: 1px solid #eee; cursor: pointer; }
.search-result-item:hover { background-color: #f0f0f0; }
.search-result-item:last-child { border-bottom: none; }
.search-result-title { font-weight: bold; font-size: 0.9em; color: var(--primary-accent); margin-bottom: 4px; }
.search-result-snippet { font-size: 0.85em; color: var(--secondary-text-color); }
.search-result-snippet mark { background-color: var(--highlight-bg); color: #333; padding: 1px; border-radius: 2px; }

/* 2. 修改: 增加平滑滚动效果 */
/*#chat-window { flex-grow: 1; overflow-y: auto; padding: 20px; scroll-behavior: smooth; }*/
/* 原样式保留，增加移动端适配 */
#chat-window {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
    /* 新增移动端适配 */
    /*max-height: 60vh; !* 限制聊天窗口最大高度 *!*/
    height: calc(100vh - 180px); /* 动态计算高度（总高度减去工具栏和输入框区域） */
}

/* 针对小屏幕进一步优化 */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden; /* 防止水平滚动[5](@ref) */
        position: fixed; /* 固定布局防止偏移 */
        width: 100%;
    }

    #app-container {
        height: 100vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    /*顶栏*/
    .toolbar-group {
        display: flex;
        align-items: center;
        gap: 8px;
        position: relative;
        color: #01080b;
        width: 43vh;
    }
    .toolbar-group label { font-size: 0.8em; color: var(--secondary-text-color); }
    #search-input, #model-selector {
        border: 1px solid var(--border-color); border-radius: 6px; padding: 6px 10px; font-size: 0.7em;
        background-color: #fff; color: var(--primary-text-color);
        width: 10vh;
    }
    #search-input, #mode-selector {
        border: 1px solid var(--border-color); border-radius: 6px; padding: 6px 10px; font-size: 0.7em;
        background-color: #fff; color: var(--primary-text-color);
        width: 10vh;
    }
    #chat-form-container {
        padding: 16px 24px;
        background-color: var(--sidebar-bg);
        border-top: 1px solid var(--border-color);
        height: 20vh;
        bottom: 100vh;
        width: 43vh;
    }
    #prompt-input-wrapper {
        display: flex;
        align-items: flex-end;
        font-size: small;
    }
    #chat-window {
        max-width: 50vh;
        max-height: 90vh; /* 限制聊天窗口最大高度 */
        height: 90vh; /* 更紧凑的高度计算 */
        padding: 10px; /* 减少内边距 */
    }

    #sidebar {
        display: flex; flex-direction: column; width: 280px; background-color: var(--sidebar-bg);
        border-right: 1px solid var(--border-color); padding: 10px; flex-shrink: 0; height: 93vh;bottom: 30%;
        box-sizing: border-box; transition: margin-left 0.3s ease-in-out;
    }
    #user-management-button {
        display: flex;
        align-items: center;
        /*height: 20%;*/
        /*bottom: 1%;*/
        width: 100%;
        padding: 6px 8px; /* 减小按钮内边距 */
        background: #DFF1FE;
        border: none;
        cursor: pointer;
        transition: background 0.2s;
        font-size: 0.9em; /* 减小字体大小 */
        border-radius: 8px;
    }

    .user-avatar {
        width: 28px; /* 减小头像尺寸 */
        height: 28px;
        margin-right: 8px; /* 减小右边距 */
    }

    .user-avatar {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      margin-right: 10px;
    }

    .user-avatar-large {
      width: 64px;
      height: 64px;
      border-radius: 50%;
      margin-bottom: 10px;
    }

    #user-panel {
      position: fixed;
      bottom: -100vh;
      left: 0;
      width: 34vh;
      height: 250px;
      background: white;
      box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
      transition: transform 0.3s ease-in-out;
      padding: 20px;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      border-radius: 10px;
    }

    #user-panel.show {
      transform: translateY(-100vh);
    }

    .user-info {
      text-align: center;
    }

    #logout-button {
      padding: 10px;
      background: #ff4d4d;
      color: white;
      border: none;
      border-radius: 4px;
      cursor: pointer;
    }

    #logout-button:hover {
      background: #ff3333;
    }
}


/* 文生图开关样式 */
.text-to-image-toggle {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.9em;
    color: var(--secondary-text-color);
}
/* 图片上传按钮图标样式 */
#image-upload + button svg path {
    fill: #4CAF50; /* 改为绿色图标 */
    transition: fill 0.3s;
}
#image-upload + button:hover svg path {
    fill: #388E3C; /* 悬停时深绿色 */
}
/* 点击时图标缩放效果 */
.icon-button:active svg {
    transform: scale(0.9);
    transition: transform 0.1s;
}
/* 音频上传按钮图标样式 */
#audio-upload + button svg path {
    fill: #2196F3; /* 改为蓝色图标 */
    d: path("M12 3v10.55c-.59-.34-1.27-.55-2-.55-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4V7h4V3h-6z"); /* 替换为波形图标路径 */
}
#audio-upload + button:hover svg path {
    fill: #1976D2; /* 悬停时深蓝色 */
}

#enable-txt2img {
    position: relative;
    width: 40px;
    height: 20px;
    -webkit-appearance: none;
    appearance: none;
    background: #ccc;
    border-radius: 20px;
    margin: 0 8px;
    cursor: pointer;
    transition: background 0.3s;
}

#enable-txt2img:checked {
    background: var(--primary-accent);
}

#enable-txt2img::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

#enable-txt2img:checked::before {
    transform: translateX(20px);
}
.message-wrapper { display: flex; margin-bottom: 10px; }
.message-wrapper.user { justify-content: flex-end; }
.message-wrapper.ai { justify-content: flex-start; }

.avatar { width: 32px; height: 32px; border-radius: 50%; background-color: var(--primary-accent); color: white;
    display: flex; align-items: center; justify-content: center; font-weight: bold; flex-shrink: 0; }
.user .avatar { background-color: #66BB6A; }

.message {
    max-width: 85%; padding: 8px 18px; border-radius: 18px; margin: 0 12px;
    line-height: 1.2; white-space: pre-wrap;
    font-size: 0.9rem; color: #222222;
    overflow-wrap: break-word;
}
.message p { margin-block-start: 0.5em; margin-block-end: 0.5em; }
.user .message { background-color: var(--user-message-bg); border-bottom-right-radius: 4px; }
.ai .message { background-color: var(--ai-message-bg); border: 1px solid var(--border-color); border-bottom-left-radius: 4px; }

.ai pre {
    margin: 12px 0; padding: 15px; border-radius: 8px; overflow-x: auto;
    background-color: #f6f8fa; /* 匹配 highlight.js github 主题的背景色 */
}
.ai code:not(pre code) {
    font-family: "Courier New", monospace; font-size: 0.9em;
    background-color: var(--border-color);
    padding: 2px 5px; border-radius: 4px;
}

#chat-form-container { padding: 16px 24px; background-color: var(--sidebar-bg); border-top: 1px solid var(--border-color); }

/* 3. 修改: 调整表单布局以容纳图片预览 */
#chat-form {
    display: flex;
    flex-direction: column; /* 改为纵向布局 */
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 20px; /* 轻微调整圆角 */
    padding: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
#prompt-input-wrapper {
    display: flex;
    align-items: flex-end;
}
/*#prompt-input {*/
/*    font-family: 'Segoe UI', 'Helvetica Neue', sans-serif; !* 现代无衬线字体 *!*/
/*    font-size: 1em;*/
/*    font-weight: 450; !* 介于常规与中等之间，避免过细 *!*/
/*    letter-spacing: 0.03em; !* 轻微字距提升流畅感 *!*/
/*    line-height: 1.6; !* 增加行高改善阅读体验 *!*/
/*    color: var(--primary-text-color);*/
/*    !* 保留原有布局属性 *!*/
/*    flex-grow: 1;*/
/*    border: none;*/
/*    background-color: transparent;*/
/*    padding: 10px 15px;*/
/*    resize: none;*/
/*    min-height: 24px;*/
/*    max-height: 200px;*/
/*    overflow-y: auto;*/
/*    outline: none;*/
/*}*/
#prompt-input {
    flex-grow: 1;
    border: none;
    background-color: transparent;
    padding: 10px 15px;
    font-family: 'Segoe UI', 'Helvetica Neue', sans-serif; /* 现代无衬线字体 */
    font-size: 1em;
    font-weight: 450; /* 介于常规与中等之间，避免过细 */
    letter-spacing: 0.03em; /* 轻微字距提升流畅感 */
    resize: none;
    min-height: 24px;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.5;
    color: var(--primary-text-color);
    outline: none;
}
.form-buttons { display: flex; align-items: center; padding-right: 5px; }
.icon-button { background: none; border: none; cursor: pointer; padding: 8px; border-radius: 50%; display: flex; transition: background-color 0.2s;}
.icon-button:hover { background-color: #e9e9e9; }
.icon-button svg { width: 24px; height: 24px; fill: var(--secondary-text-color); }
#send-button svg { fill: var(--primary-accent); }

/* 3. 新增: 图片预览相关样式 */
#image-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0 15px 8px;
}
#image-preview-container:empty {
    display: none; /* 没有图片时隐藏容器 */
}
.img-preview-wrapper {
    position: relative;
    display: inline-block;
}
.img-preview-wrapper img {
    height: 70px;
    width: 70px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.img-preview-remove-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    /* justify-content: center;gemini-2.5-flash
    background-color: rgba(0, 0, 0, 1); */
}